package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GFactorType;
import com.gzck.gzck_verson2.service.IGFactorTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 要素类型表-解析报文用 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-factor-type")
public class GFactorTypeController {

    @Autowired
    private IGFactorTypeService factorTypeService;

    // 添加要素类型
    @PostMapping("/add")
    public boolean addFactorType(@RequestBody GFactorType factorType) {
        return factorTypeService.save(factorType);
    }

    // 删除要素类型
    @DeleteMapping("/delete/{id}")
    public boolean deleteFactorType(@PathVariable Long id) {
        return factorTypeService.removeById(id);
    }

    // 更新要素类型信息
    @PutMapping("/update")
    public boolean updateFactorType(@RequestBody GFactorType factorType) {
        return factorTypeService.updateById(factorType);
    }

    // 查询单个要素类型信息
    @GetMapping("/{id}")
    public GFactorType getFactorType(@PathVariable Long id) {
        return factorTypeService.getById(id);
    }

    // 查询所有要素类型信息
    @GetMapping("/all")
    public List<GFactorType> getAllFactorTypes() {
        return factorTypeService.list();
    }
}
